//
// Created by xili on 2024/8/21 18:42.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution1 {
public:
    string addSpaces(string s, vector<int> &spaces) {
        int i = 0;
        for (auto &item: spaces) {
            s.insert(item + (i++), " ");
        }
        return s;
    }
};

class Solution2 {
public:
    string addSpaces(string s, vector<int> &spaces) {
        string res;
        int p = 0;
        for (int i = 0; i < s.length(); ++i) {
            if (p < spaces.size() && i == spaces[p]) {
                ++p;
                res.push_back(' ');
            }
            res.push_back(s[i]);
        }
        return res;
    }
};
